package com.atguigu.gulimall.product.entity;

import com.atguigu.common.valid.anno.ListValue;
import com.atguigu.common.valid.group.AddGroup;
import com.atguigu.common.valid.group.UpdateGroup;
import com.atguigu.common.valid.group.UpdateStatusGroup;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 * 
 * @author leifengyang
 * @email sunlightcs@gmail.com
 * @date 2022-10-22 21:23:50
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@TableId
	@JsonFormat(shape = JsonFormat.Shape.STRING)
	@Null(groups = {AddGroup.class}, message = "新增不能指定ID")
	@NotNull(groups = {UpdateGroup.class}, message = "修改需要指定ID")
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotEmpty(groups = {AddGroup.class, UpdateGroup.class},message = "品牌名不能为空")
	private String name;
	/**
	 * 品牌logo地址
	 */
	@URL(groups = {AddGroup.class, UpdateGroup.class}, message = "logo必须是一个合法的URL地址")
	@NotBlank(groups = {AddGroup.class}, message = "logo地址不能为空")
	private String logo;
	/**
	 * 介绍
	 */
	@NotEmpty(groups = {AddGroup.class, UpdateGroup.class}, message = "介绍不能为空")
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@ListValue(groups = {AddGroup.class, UpdateGroup.class, UpdateStatusGroup.class}, values = {0, 1})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@Pattern(groups = {AddGroup.class, UpdateGroup.class}, regexp = "^[a-zA-Z]$", message = "首字母必须是a-z 或 A-Z 之间, 且必须填写")
	@NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "检索首字母不能为空")
	private String firstLetter;
	/**
	 * 排序
	 */
	@Min(groups = {AddGroup.class, UpdateGroup.class}, value = 0, message = "排序必须大于等于0")
	@NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "排序不能为空")
	private Integer sort;

}
